package cn.com.guage.string;

public class StringReverse {

	public StringReverse() {
	}

	public static void main(String[] args) {

		String str = "abcdefg";
		reverse(str);
		reverse2(str);
		 reverse3(str);

	}

	public static void reverse(String str) {
		String[] arry = str.split("");
		int length = str.length() - 1;
		StringBuffer buffer = new StringBuffer();
		for (int i = length; i >= 0; i--) {
			buffer.append(arry[i]);
		}
		System.out.println(buffer.toString());
	}

	public static void reverse2(String str) {
		String reverse = "";
		char[]  array = str.toCharArray();
		for(int i = 0; i<array.length;i++) {
			reverse = array[i]+reverse;
		}
       System.out.println(reverse);
	}
	
	public static void reverse3(String str) {
		StringBuffer buffer = new StringBuffer(str);
		buffer.reverse();
		System.out.println(buffer.toString());
	}
}
